import React from 'react'
import {
    Switch,
    Redirect,
    Route,
} from "react-router-dom"
import BeforEach from "./BeforEach"

const Routerview = (props) => {
    const { routes } = props;
    return (
        <Switch>
            {
                routes.length && routes.map((item, index) => {
                    return item.path ? <Route key={index} path={item.path} render={(props) => <BeforEach {...props} {...item} />} />
                        : <Redirect key={index} from={item.from} to={item.to} exact />
                })
            }
        </Switch>
    )
}

export default Routerview
